package ch11;

import java.util.TreeSet;

class _14_TreeSetEx {
	public static void main(String[] args) {
		TreeSet<String> set = new TreeSet<String>();

		String from = "b";
		String to = "d";

		set.add("abc");
		set.add("alien");
		set.add("bat");
		set.add("car");
		set.add("disc");
		set.add("dance");
		set.add("dzzzz");
		set.add("elephant");		

		System.out.println(set); // [abc, alien, bat, car, dance, disc, dzzzz, elephant]
		System.out.println("range search : from " + from + " to " + to); // range search : from b to d
		System.out.println("result1 : " + set.subSet(from, to)); // result1 : [bat, car]
		System.out.println("result2 : " + set.subSet(from, to + "zzz")); // result2 : [bat, car, dance, disc]
	}
}